cmake_minimum_required(VERSION 3.5)

project(Conditional LANGUAGES CXX)

set(USE_LIBRARY OFF)
message(STATUS "Compile sources into a library? ${USE_LIBRARY}")

set(BUILD_SHARED_LIBS OFF)

list(APPEND _sources Message.h Message.cpp)

if(USE_LIBRARY)

  add_library(message STATIC  ${_sources} )
  add_executable(helloCmake main.cpp)
  target_link_libraries(helloCmake message)
else()
  add_executable(helloCmake main.cpp ${_sources} )
endif()